from datetime import datetime
from applications.extensions import db

def get_current_time():
    create_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    return datetime.strptime(create_at, "%Y-%m-%d %H:%M:%S")

class Device_request(db.Model):
    __tablename__ = 'device_request'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="ID")
    requesterId = db.Column(db.Integer, comment="申请人ID")
    requesterName = db.Column(db.String(30), comment="申请人名称")
    auditerName = db.Column(db.String(30), comment="审核人名称")
    auditerId = db.Column(db.Integer, comment="审核人ID")
    type = db.Column(db.Integer, comment="申报类型：1表示报废、2表示采购")
    status = db.Column(db.Integer, comment="申报状态：0表示未审核、1表示通过、2表示驳回", default=0)
    formId = db.Column(db.Integer, comment="用于连接对应数据表之中的ID序号")
    create_at = db.Column(db.DateTime, default=get_current_time(), comment='申报时间')
    audit_at = db.Column(db.DateTime, comment='审核时间')
    audit_reason = db.Column(db.String(200), comment='原因')